class_name StaticEntity
extends StaticBody2D

##获取 entity_data
##[codeblock]
##var data = entity.get_entity_data()
##[/codeblock]
##获取 component
##[codeblock]
##var component = entity.get_component_by_name("")
##[/codeblock]
@export var entity_data:EntityData
var blackboard_data:BlackboardData
var component_dict:Dictionary

func init():
	pass
func get_entity_data():
	return entity_data
func get_blackboard_data(key:String):
	return blackboard_data.get_data(key)
func set_blackboard_data(key:String,value):
	blackboard_data.set_data(key,value)
func get_blackboard_data_dict():
	return blackboard_data.get_data_dict()
func clear_blackboard_data_dict():
	blackboard_data.clear_data_dict()
func get_components() -> Array[BaseComponent]:
	var components:Array[BaseComponent] = []
	for child in get_children():
		if child is BaseComponent:
			components.append(child)
	components.sort_custom(func (a,b):return a.priority < b.priority)
	return components
func get_component_dict() -> Dictionary:
	return component_dict
func get_component_by_name(component_name:String) -> BaseComponent:
	if component_dict.has(component_name):
		return component_dict[component_name]
	return null

func _init() -> void:
	blackboard_data = BlackboardData.new()
	component_dict = {}
func _ready() -> void:
	for child in get_components():
		component_dict[child.component_name] = child
		child.init_component(self)
func _process(delta: float) -> void:
	pass
